//
//  NetworkConfig.m
//  AFNetworking
//
//  Created by admin on 2020/5/19.
//

#import "NetworkConfig.h"
static NetworkConfig *networkConfig = nil;


@implementation NetworkConfig

+(NetworkConfig *)share{
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        networkConfig = [NetworkConfig new];
        NSDictionary *defual = [[NSUserDefaults standardUserDefaults] objectForKey:@"store.network.config"];
        if (defual) {
            [networkConfig modelSetWithJSON:defual];
        }else{
            [networkConfig modelSetWithJSON:[NetworkConfig configArr].firstObject];
        }
        
    });
    return networkConfig;
}
-(NSString *)storeVue{
    if (_isLocal) {
        return _storeHost;
    }else{
        return _storeWeb;
    }
}

+(NSArray*)configArr{
    NSString* path = [[NSBundle mainBundle] pathForResource:@"StortVue" ofType:@"bundle"];
    NSBundle *bundle = [NSBundle bundleWithPath:path];
    return @[
        @{@"title":@"10.10.11.171",
          @"storeHost":@"http://10.10.11.171:15674",
          @"storeWeb":@"http://10.10.11.171:15676",
          @"storeLocal":[bundle URLForResource:@"index" withExtension:@"html"]
        }
    ];
}

+(void)save{
    [[NSUserDefaults standardUserDefaults] setObject:[self modelToJSONObject] forKey:@"store.network.config"];
}
@end
